<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .active {
            color: red;
        }
    </style>

</head>

<body>

    <!-- 我们可以使用 v-bind 指令将待办项传到循环输出的每个组件中： -->
    <div id="app">
        <ol>
            <!-- 为每一个todo-item对象提供todo对象 todo对象是变量 即内容是动态的 -->
            <todo-item
            v-for="item in groceryList"
            v-bind:to="item"
            v-bind:key="item.id"
           >    
            </todo-item>
        </ol>

    </div>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script>
        Vue.component('todo-item', {
            props: ['to'],
            template: "<li>{{to.text}}</li>",
        })
        var app = new Vue({
            el: "#app",
            data: {
                groceryList: [
                    { id: 0, text: '蔬菜' },
                    { id: 1, text: '奶酪' },
                    { id: 2, text: '随便其它什么人吃的东西' }
                ]
            }
        })


    </script>
</body>

</html>